#include "statsdisplay.h"

StatsDisplay::StatsDisplay(QGraphicsScene *scene)
    : QGraphicsSimpleTextItem(0,scene)
{
    startPopulation = 0;
    currentPopulation = 0;
    infectedPeople = 0;
    infectivity = 0;

    QString convertString;

    QFont tempFont = QFont();
    tempFont.setBold(true);
    tempFont.setPointSize(10);
    setFont(tempFont);

    setText(QString("Population: ") + convertString.setNum(startPopulation) +
            QString("\nInfected People: ") + convertString.setNum(infectedPeople) +
            QString("\nStarting Population: ") + convertString.setNum(startPopulation) +
            QString("\nInfectivity: ") + convertString.setNum(infectivity));
}

void StatsDisplay::setStartPopulation(int population)
{
    startPopulation = population;

    QString convertString;
    QString currentString;
    currentString = QString("              Population: ");
    currentString.append(convertString.setNum(currentPopulation));
    currentString.append(QString("\n      Infected People: "));
    currentString.append(convertString.setNum(infectedPeople));
    currentString.append(QString("\nStarting Population: "));
    currentString.append(convertString.setNum(startPopulation));
    currentString.append(QString("\n          Infectivity: "));
    currentString.append(convertString.setNum(infectivity));

    setText(currentString);
}

void StatsDisplay::setStats(int population, int infectedPopulation, int averageInfectivity, int updateSpeed, QString playTime)
{
    currentPopulation = population;
    infectedPeople = infectedPopulation;
    infectivity = averageInfectivity;

    QString convertString;
    QString currentString;
    currentString = QString("              Population: ");
    currentString.append(convertString.setNum(currentPopulation));
    currentString.append(QString("\n      Infected People: "));
    currentString.append(convertString.setNum(infectedPeople));
    currentString.append(QString("\nStarting Population: "));
    currentString.append(convertString.setNum(startPopulation));
    currentString.append(QString("\n              Infectivity: "));
    currentString.append(convertString.setNum(infectivity));
    currentString.append(QString("\n         Update Speed: "));
    currentString.append(convertString.setNum(updateSpeed));
    currentString.append(QString("\n           Play Time: "));
    currentString.append(playTime);

    setText(currentString);
}
